package com.dd2086.activemqTest;

import javax.jms.Queue;
import javax.jms.Topic;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Producer {
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;
    @Autowired
    private Topic topic;

    @RequestMapping("/sendMsg")
    public void sendMsg(String msg) {
    	System.out.println("=============发送Queue消息咯:"+msg);
        this.jmsMessagingTemplate.convertAndSend(this.queue,msg);
    }
    
    @RequestMapping("/sendTopic")
    public void sendTopic(String msg) {
    	System.out.println("=============发送TOPIC消息咯:"+msg);
    	this.jmsMessagingTemplate.convertAndSend(this.topic,msg);
    }
    
    @JmsListener(destination="out.queue")  
    public void consumerMessage(String text){  
        System.out.println("从out.queue队列收到的回复报文为:"+text);  
    }
    
}